package com.design.memento.multimemento;

/**
 * @ClassName Originator.java
 * @Description 发起人角色
 * @author Jon
 * @date 2018年6月20日 下午5:15:44
 */
public class Originator {
	private String state = "";
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	/**   
	 * Description	创建一个备忘录  		
	 */ 
	public Memento createMemento() {
		return new Memento(state);
	}
	/**   
	 * Description	恢复备忘录  		
	 */ 
	public void restoreMemento(IMemento memento) {
		this.setState(((Memento) memento).getState());
	}
	/**
	 * @Description 内置类
	 */
	private class Memento implements IMemento {
		private String state = "";
		public Memento(String state) {
			this.state = state;
		}
		private String getState() {
			return state;
		}

		@SuppressWarnings("unused")
		private void setState(String state) {
			this.state = state;
		}
	}
}
